package guda.house.biz.form.rule;

import guda.house.biz.util.PriceUtil;
import guda.house.dal.dataobject.ExtRuleDO;

import javax.validation.constraints.NotNull;

/**
 * Created by well on 15/11/12.
 */
public class ExtRuleEditForm extends ExtRuleForm{

    @NotNull(message = "不能为空")
    private Long ruleId;

    public Long getRuleId() {
        return ruleId;
    }

    public void setRuleId(Long ruleId) {
        this.ruleId = ruleId;
    }

    public void initForm(ExtRuleDO extRuleDO){
        setRuleId(extRuleDO.getRuleId());
        setRuleStatus(extRuleDO.getRuleStatus());
        setVarId(extRuleDO.getVarId());
        setFee(PriceUtil.formatCNY(extRuleDO.getFee()));
        setVillageId(extRuleDO.getVillageId());
    }

    public ExtRuleDO toDO() {
        ExtRuleDO extRuleDO = super.toDO();
        extRuleDO.setRuleId(ruleId);
        return extRuleDO;
    }
}
